import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import { mars3dPlugin } from 'vite-plugin-mars3d';
// https://vitejs.dev/config/
export default defineConfig({
  base: "/zoon", // 加这句基础路径即可
  plugins: [
    vue(),
    mars3dPlugin()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  build: {
    chunkSizeWarningLimit: 5000 // 将限制调高到 1000 kB
  },

  server: {
    host: "0.0.0.0", //ip地址
    port: 8086, //端口号
    open: false, //启动后是否自动打开浏览器
    proxy: {
      '/api': {
        // target: 'http://123.150.5.131:8080',
        target: 'https://qilihai.baohuqu.net:8080',
        changeOrigin: true, 
        rewrite: path => path.replace(/^\//, '')
      },
      // '/vocalfile': {
      //   target: 'http://123.150.5.131:8080/',
      //   changeOrigin: true, 
      //   rewrite: path => path.replace(/^\/vocalfile/, '')
      // },
       "/donghai": {
        target: "https://qilihai.baohuqu.net:8080/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\//, ""),
      },
      "/xihai": {
        target: "https://qilihai.baohuqu.net:8080/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\//, ""),
      },
    },
  },
})
